<template>
  <el-row :gutter="15">
    <el-col :span="24">
      <el-form class="el-form-col" label-width="104px" :label-position="labelPosition">
        <el-card>
          <div slot="header" class="clearfix">
            <span>盘库详情</span>
          </div>
          <el-row :gutter="15">
            <template v-if="detail.state == '1'">
              <el-col :lg="6" :md="12">
                <el-form-item label="盘点仓库:">
                  <span>{{ detail.inventoryWarehouseName }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="盘点区域:">
                  <span>{{ detail.inventoryDistrict }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="创建人:">
                  <span>{{ detail.founderName }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="创建时间:">
                  <span>{{ detail.foundtime | unixTimestampFilter }}</span>
                </el-form-item>
              </el-col>
            </template>
            <template v-if="detail.state == '2'">
              <el-col :lg="6" :md="12">
                <el-form-item label="盘库编号:">
                  <span>{{ detail.code }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="盘点区域:">
                  <span>{{ detail.inventoryDistrict }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="创建人:">
                  <span>{{ detail.founderName }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="创建时间:">
                  <span>{{ detail.foundtime | unixTimestampFilter }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="库存包件总数:">
                  <span class="font-red">{{ detail.realityAll }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="实际包件总数:">
                  <span class="font-red">{{ detail.inventoryAll}}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="盘盈总数:">
                  <span class="font-red">{{ detail.inventoryYi }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="盘亏总数:">
                  <span class="font-red">{{ detail.inventoryKui }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="提交人:">
                  <span>{{ detail.updaterName }}</span>
                </el-form-item>
              </el-col>
              <el-col :lg="6" :md="12">
                <el-form-item label="提交时间:">
                  <span>{{ detail.updatetime | unixTimestampFilter }}</span>
                </el-form-item>
              </el-col>
            </template>
          </el-row>
        </el-card>
      </el-form>
    </el-col>
    <el-col :span="24" v-if="detail.state == '1'">
      <Portlet>
        <Conduct ref="Conduct" :inventoryId="id" :detail="detail"></Conduct>
      </Portlet>
    </el-col>
    <el-col :span="24" v-if="detail.state == '2'">
      <BasicTable
        ref="BasicTable"
        url="/ms-warehouse-order/inventory/findInventoryItemExtList"
        :columns="columns"
        :tabs="tabs"
      >
      </BasicTable>
    </el-col>
  </el-row>
</template>

<script>
import {unixTimestampFilter} from '@/filters'
import Conduct from '@/views/oms/warehouse/inventory/Conduct'
export default {
  name: 'warehouseInventoryShow',
  components: {
    Conduct
  },
  filters: {
    unixTimestampFilter
  },
  data() {
    let that = this
    return {
      id: this.$route.params.id,
      labelPosition: 'left',
      detail: {},
      columns: [
        {label: '所在库位', data: 'locationName'},
        {label: '所在商家', data: 'cargoOwnerName'},
        {label: '产品编号', data: 'productNo'},
        {label: '所属产品', data: 'productName'},
        {label: '包件编号', data: 'packageCode'},
        {label: '包件名称', data: 'packageName'},
        {label: '库存包件数量', data: 'realityNum'},
        {label: '实际包件数量', data: 'inventoryRealityNum'},
        {label: '责任人', data: 'dutyMan'},
        {label: '备注', data: 'memo'}
      ],
      tabs: [
        {
          label: '全部包件',
          callback(params) {
            params.state = 0
            params.inventoryId = that.id
            that.state = 0
          }
        },
        {
          label: '盘溢包件',
          callback(params) {
            params.state = 1
            params.inventoryId = that.id
            that.state = 1
          }
        },
        {
          label: '盘亏包件',
          callback(params) {
            params.state = 2
            params.inventoryId = that.id
            that.state = 2
          }
        }
      ]
    }
  },
  created() {
    this.getDetail()
  },
  methods: {
    unixTimestampFilter,
    getDetail() {
      this.$ajax.get('/ms-warehouse-order/inventory/findInventoryInfo', {inventoryId: this.id}).then(response => {
        if (response.success) {
          this.detail = response.data
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
